﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Logic;

namespace web_CategoryMS.View.G01
{
    public partial class FS0101_Sub1 : System.Web.UI.Page
    {
        FS0101_SubLogic fs0101_SubLogic = new FS0101_SubLogic();
        #region 初始化方法
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

            }
        }
        #endregion

        #region 保存事件
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region 输入校验
                if (string.IsNullOrEmpty( txtUserID.Text.Trim()))
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "alert('请输入用户ID！');", true);
                }
                if (string.IsNullOrEmpty(txtPassword1.Text.Trim()) || string.IsNullOrEmpty(txtPassword2.Text.Trim()))
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "alert('请输入密码！');", true);
                }
                if (txtPassword1.Text.Trim() != txtPassword2.Text.Trim())
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "alert('两次输入的密码不一致，请重新输入！');", true);
                }
                if (string.IsNullOrEmpty(ddlUserType.SelectedValue))
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "alert('请选择用户类别！');", true);
                }
                #endregion

                string strRes = fs0101_SubLogic.Save(txtUserID.Text.Trim(), txtPassword1.Text.Trim(), ddlUserType.SelectedValue);
                if (string.IsNullOrEmpty(strRes))
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "window.opener.recall();window.close();", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "", "alert('" + strRes + "')", true);
                }
            }
            catch (Exception ex)
            {
                
            }
        }
        #endregion
    }
}